<?php
// +----------------------------------------------------------------------
// | Copyright (c) 2023 yoncron All rights reserved.
// +----------------------------------------------------------------------
// | Author: yoncron <yoncron@163.com>
// +----------------------------------------------------------------------
namespace app\controller\app\im;

use app\controller\app\AppBase;
use app\model\view\NearbyUserView;
use app\service\Route;

class Nearby extends AppBase
{
    /**
     * description:附近的人
     * @Route(reqUrl="/im.nearby.user.lst")
     * author:yoncron<yoncron@163.com>
     * data:2023/11/03
     */
    public function lst(){
        $lon=input('lon');
        $lat=input('lat');
        $page=input('page',1);
        $nearbyUserViewObj = new NearbyUserView();
        $lst = $nearbyUserViewObj->lst($this->app_id,$this->user_id,$lon,$lat,$page,20);
        foreach($lst as &$item){
            $item['distance'] =ceil(($item['distance'] * 10));
            if($item['distance']<10){

                $item['distance']=$item['distance'].'00米';
            }
            else{
                $item['distance']=($item['distance']/10).'公里';
            }
        }
        $res['code'] = 0;
        $res['list'] = $lst;
        return json($res);
    }
}